﻿<!DOCTYPE HTML>
<html>
{include file="public:header_css"}
<body>
<nav class="breadcrumb">
	<i class="Hui-iconfont">&#xe67f;</i> 首页 <span class="c-gray en">&gt;</span> 公告管理 <span class="c-gray en">&gt;</span> 公告列表
	<a class="btn btn-success radius r" style="line-height:1.6em;margin-top:3px" href="javascript:location.replace(location.href);" title="刷新" ><i class="Hui-iconfont">&#xe68f;</i></a>
</nav>
<div class="page-container">
    <div class="cl pd-5 bg-1 bk-gray mt-20">
        <span class="l">
            <a class="btn btn-primary radius" href="{:url('add')}">
				<i class="Hui-iconfont">&#xe600;</i> 添加公告
			</a>
		</span>
        <span class="r">共有数据：<strong>{$total}</strong> 条</span>
	</div>

	<div class="mt-20">
		<table class="table table-border table-bordered table-bg table-hover table-sort">
			<thead>
			<tr class="text-c">
				<th width="80">ID</th>
				<th width="150">标题</th>
				<th width="150">所选门店</th>
				<th width="60">优先级别</th>
				<th width="60">状态</th>
				<th width="60">操作</th>
			</tr>
			</thead>
			<tbody>
			{foreach name="notice_list" item="v" key="k"}
			<tr class="text-c">
				<td>{$v.id}</td>
				<td class="text-l">{$v.title}</td>
				<td class="text-c">{$v.store_name}</td>
				<td>
					<input type='text' size='8' data-id="{$v.id}" value='{$v.sort}' class='list_sort' id="sort" style="border: 0.5px solid orange;height: 25px;text-align: center;">
				</td>
				<td class="td-status">
					{if $v.is_show == 1}
						<span class="label label-success radius" onClick="is_show('{$v.id}',0)" href="javascript:;">点击隐藏</span>
					{else}
						<span class="label label-danger radius" onClick="is_show('{$v.id}',1)" href="javascript:;">点击显示</span>
					{/if}
				</td>
				<td class="td-manage">
					<a style="text-decoration:none" class="ml-5" href="{:url('edit',array('id'=>$v['id']))}" title="编辑">
						<i class="Hui-iconfont" style="font-size:20px;">&#xe6df;</i>
					</a>
				</td>
			</tr>
			{/foreach}
			</tbody>
		</table>
	</div>

	{$page}

</div>

{include file="public:footer_js"}

<script type="text/javascript" src="__STATIC__/admin/lib/layer/2.4/layer.js"></script>

<script type="text/javascript">

	//排序聚焦
    $(".list_sort").focus(function(){
        $(this).css("border","0.5px solid grey");
    });
	//排序失焦
    $(".list_sort").blur(function(){

        $(this).css("border","0.5px solid orange");

        var id = $(this).attr("data-id");

        //异步提交
        $.post(
            '{:url("sort")}?id='+id,
            {
                sort: $(this).val()
            },
            function (res) {
                if(res.code === 1){
                    layer.msg(res.msg,{icon:6,time:1000});

                    // 两秒后跳转到列表页
                    setTimeout(function () {
                        location.replace(location.href);
                    },2000);

                }else{
                    layer.msg(res.msg,{icon:5,time:1000});
                }
            }
        );

    });

	/**
	 * 是否启用
	 */
	function is_show(id,is_show){
	    var notice = "确定隐藏吗？";
        if(status === 0){
            notice = "确定显示吗？";
        }
		if(status === 1){
	        notice = "确定隐藏吗？";
		}

		layer.confirm(notice,function (index) {
			$.post(
			    '{:url("edit")}?id='+id,
				{
				    is_show:is_show
				},
				function (res) {
			        if(res.code === 1){
                        layer.msg(res.msg,{icon:6,time:1000});

                        // 两秒后跳转到列表页
						setTimeout(function () {
                            location.replace(location.href);
                        },2000);

					}else{
                        layer.msg(res.msg,{icon:5,time:1000});
					}
                }
			);
        });

	}

</script>
</body>
</html>